package com.aiyige.page.publish.selectcourse.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.aiyige.R;
import com.aiyige.page.publish.selectcourse.model.Course;
import com.aiyige.page.publish.selecttraingcard.model.TraingCard;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.LinkedList;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by zhuyakun on 2018/3/23.
 */

public class CourseAdapter extends BaseQuickAdapter<Course, CourseAdapter.ViewHolder> {

    public CourseAdapter() {
        super(R.layout.select_course_item, new LinkedList<Course>());
    }

    @Override
    protected void convert(ViewHolder helper, Course item) {
        helper.bindData(item);
    }

    public class ViewHolder extends BaseViewHolder {

        @BindView(R.id.courseTypeTv)
        TextView courseTypeTv;
        @BindView(R.id.courseTitleTv)
        TextView coruseTitleTv;
        @BindView(R.id.selectIv)
        ImageView selectIv;

        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }

        public void bindData(Course course) {
            switch (course.getType()) {
                case Course.TYPE_MAJOR_COURSE:
                    courseTypeTv.setText(R.string.major_course_label);
                    break;
                case Course.TYPE_TRAING_CLASS:
                    courseTypeTv.setText(R.string.traing_class_label);
                    break;
            }
            if (course.isSelected()) {
                selectIv.setImageResource(R.drawable.interest_elect);
            } else {
                selectIv.setImageResource(R.drawable.interest_normal);
            }
            coruseTitleTv.setText(course.getTitle());
        }
    }
}
